import java.io.*;
import java.net.*;

public class SocketClientClass {
    Socket socket = null;
    InputStream is = null;
    OutputStream os = null;
    String serverIP = "127.0.0.1";
    int port = 10001;
    public void run() throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        socket = new Socket(serverIP, port);
        os = socket.getOutputStream();
        is = socket.getInputStream();
        byte[] b = new byte[8192];
        while (true){
            String data = br.readLine();
            //System.err.println("Data\t" + data);
            if (data.startsWith("end")) break;
            os.write(data.getBytes());
            int n = is.read(b);
            System.out.println("Feedback from Server:\t" + new String(b, 0, n));
        }
    }
    public void start(){
        this.start(this.serverIP, this.port);
    }
    public void start(String serverIP, int port) {
        this.serverIP = serverIP;
        this.port = port;
        try {
            run();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
                os.close();
                socket.close();
            } catch (Exception e2) {}
        }
    }
    public static void main(String[] argv){
        SocketClientClass client = new SocketClientClass();
        client.start();
    }
}
